package saxion.speelveld.spaceengineer;

import java.util.ArrayList;

import saxion.speelveld.spaceengineer.controller.AchievementRowAdapter;
import saxion.speelveld.spaceengineer.database.AchievementDAO;
import saxion.speelveld.spaceengineer.model.Achievement;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;

public class AchievementScreen extends Activity
{

	private AchievementDAO AchievementDatabase;

	private ArrayList<Achievement> achievementList;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_achievement_screen);

		ListView listview = (ListView) findViewById(R.id.list);

		// added by Maarten:
		AchievementDatabase = new AchievementDAO(this.getApplicationContext());
		//

		AchievementDatabase.open();
		achievementList = AchievementDatabase.getAllAchievements();
		AchievementDatabase.close();

		AchievementRowAdapter adapter = new AchievementRowAdapter(this, achievementList);
		listview.setAdapter(adapter);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_achievement_screen, menu);
		return true;
	}

}